Tags: plugin
Edition: creative
Tagline: Blur, sharpen, remove noise, and perform automatic histogram adjustment. Plus several other cool effects. 
Icon: cogs
Aliases: /plugins/advancedfilters
Textclass: none


h1 AdvancedFilters plugin 

.markdown-body
  markdown:
    Apply advanced effects to your images. These are implemented in C#. Those which touch each pixel hundreds of times (like sharpen, blur, remove noise, and oilpainting) can perform poorly on large images.

    If you just want sharpening, use the Fastscaling plugin and `&f.sharpen` instead. `f.sharpen` adds no performance overhead, and produces better results (it is integrated with the resampling phase). `f.sharpen` is also supported by Imageflow.

	**This plugin is not forwards-compatible. Avoid these URL commands for maximum compatibility with Imageflow and future major ImageResizer releases.**



- image_width = 400 
- cache_buster = "000006"

- canny_options = ["a.canny=true"]
/ possible error induced by call below
/ - painting_options = ["a.oilpainting=1", "a.oilpainting=50", "a.oilpainting=100"]
- painting_options = []
- balance_options = ["a.balancewhite=true","a.balancewhite=area","a.balancewhite=simple","a.balancewhite=gimp", "a.balancethreshold=0.06", "a.balancethreshold=0.6"]
- sepia_options = ["a.sepia=true"]
- histogram_options = ["a.equalize=true"]
- contrast_options = ["a.contrast=-0.1", "a.contrast=0.1"]
- brightness_options = ["a.brightness=-0.1", "a.brightness=0.1"]
- saturation_options = ["a.saturation=-0.2", "a.saturation=0.2"]

- image_options =  canny_options + painting_options + sepia_options + histogram_options + balance_options + contrast_options + saturation_options


.row-fluid
  .span8.well
    .slider
      #flex1.flexslider
        ul.slides
          - random_image = "%03d" % Random.new.rand(1..30)
          - image_options.each do | opt |
            li
              img src="http://z.zr.io/rw/pluginexamples/example-#{random_image}.jpg?format=png&width=#{image_width}&#{opt}"
              .slide-caption.n.hidden-phone
                - if canny_options.include? opt
                  h3 Canny Edge Detector
                - if painting_options.include? opt
                  h3 Oil Painting Effect
                - if balance_options.include? opt
                  h3 White Balance
                - if sepia_options.include? opt
                  h3 Sepia
                - if histogram_options.include? opt
                  h3 Automatic Histogram Adjustment
                - if brightness_options.include? opt
                  h3 Brightness
                - if contrast_options.include? opt
                  h3 Contrast
                - if saturation_options.include? opt
                  h3 Saturation
                p #{opt}
          ul.flex-direction-nav
            li: a.flex-prev href="#" Previous
            li: a.flex-next href="#" Next    
    br
    br
    p
      | Refresh for another image.
.markdown-body
  .t
    markdown:
      ## Installation

      Either run `Install-Package ImageResizer.Plugins.AdvancedFilters` in the NuGet package manager, or:

      1. Add `ImageResizer.Plugins.AdvancedFilters.dll` to your project. Make sure `AForge.dll`, `AForge.Math.dll`, and `AForge.Imaging.dll` are copied also, although they do not need to be referenced directly.
      2. Add `<add name="AdvancedFilters" />` inside `<resizer><plugins></plugins></resizer>` in Web.config.

      ## Usage

      * Gaussian blur with adjustable radius: `&a.blur=radius`
      * Gaussian sharpen with adjustable radius: `&a.sharpen=radius`


      ## Alpha effects (may change or disappear without notice)

      **Please note the following effects are only preset for evaluation. If you like one and find a practical use for it, please let me know! Otherwise it might disappear to reduce the code surface area.**

      **Also, note the order in which effects are applied *WILL CHANGE* in future releases.** Don't combine them if you want repeatable results.

      **The names for these will probably also change in future releases.**

      ### Contrast, saturation, and brightness adjustment

      Hint: Start with values between -0.1 and 0.1. Values have a big effect.

      * `a.contrast=-1..1`
      * `a.saturation=-1..1`
      * `a.brightness=-1..1`

      ### Automatic white balance (alpha feature of v3.3.0+)

      Automatically corrects the white balance of the photo with 1 of 3 algorithms.

      * `area` - Threshold is applied based on cumulative area at the lower and upper ends of the histogram. Much larger thresholds are required for this than SimpleThreshold.
      * `simple` - Simple upper and lower usage thresholds are applied to the values in each channel's histogram to determine the input start/stop points for each individual channel. The start/stop points are used to calculate the scale factor and offset for the channel.
      * `gimp` - Threshold is applied based on strangely skewed cumulative area, identical to the process used by GIMP.

      The default (and recommended) algorithm is 'area'.

      * `&a.balancewhite=true|area|simple|gimp`
      * `&a.balancethreshold=0.6|0.06` (simple white balance requires a smaller threshold.)

      For the `area` and `gimp` algorithms, the default threshold is 0.6. For `simple` 0.06 is used (as it is not compared against cumulative area, but an individual value's usage)


      ### Automatic histogram adjustment (Good for daylight photos)

      Adjusts contrast, saturation, and brightness with curves based on the histogram. Good for adjusting slightly foggy or dark daytime photos.

      * `a.equalize=true`

      ### Sepia

      Sepia effect, slightly different from the one in SimpleFilters... going to evaluate which is best.

      * `a.sepia=true`

      ### Oil Painting effect

      Try `1` for impressionist, `100` for modern art ;)

      * `a.oilpainting=1..100`

      ## Noise removal

      Not a blur effect - designed to remove color noise, 'pepper noise'. Very conservative, doesn't affect edges.

      * `a.removenoise=1-100`


      ### Sobel energy filter

      Useful only for debugging why [whitespace trimmer](/plugins/whitespacetrimmer) isn't working on an image.

      * `a.sobel=true`

      Note - you can also threshold the sobel filter into black and white with &amp;a.threshold=0-255

      ### Canny Edge Detector

      Displays edges as lines. Aggressive.

      * `a.canny=true`
